#!/usr/bin/env python 2
#coding:utf-8

import md5
import os


f="1.jpg"
f1="2.jpg"
f3="8.jpg"

#print md5.md5sum(f)
#print md5.md5sum(f1)
#Ωprint md5.md5sum(f3)
li=[]
def getfiles(dir):
	files=os.listdir(dir)
	for f in files:
		ext=os.path.splitext(f)[1] ;
		print ext
		if(os.path.splitext(f)[1] not in [".jpg",".jpeg"]):
			print "%s not  a image" %f
			pass;
		
		fname=dir+'/'+f;
		if os.path.isdir(fname):
			getfiles(fname)
		else:	
			li.append(fname)
getfiles("/Volumes/picture/照片");   





fi=open("file.log","w")
log=open('log','w')
print len(li)
dict={}
for f in li:
	md5s=md5.md5sum(f);
	if dict.has_key(md5s) :
		print dict[md5s]
		log.write( "%s 已经存在,和%s 重复" %(f,dict[md5s])+"\r\n")
		fi.write(f+"\r\n")
	dict[md5s]=f

fi.close()
log.close()
	
	
	
